package com.efuture.androidmvvmdemo.viewmodel

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.efuture.androidmvvmdemo.base.BaseModel
import com.efuture.androidmvvmdemo.net.ApiParameter
import com.efuture.androidmvvmdemo.net.NetService
import com.efuture.netrequestdemo.bean.Project
import com.efuture.netrequestdemo.bean.User
import com.efuture.netrequestdemo.utils.AppGlobal
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch

/**

 *@description:TODO
 * @author: zhaoshanshan
 * @date: 2022/3/27 1:15 下午

 */
class MainViewModel:BaseModel() {

    val homeData = MutableLiveData<Project>()
    val userData = MutableLiveData<User>()

    fun getHomeData(cid:String){
        viewModelScope.launch(Dispatchers.Main) {
            val projectData: Project? = NetService.request(ApiParameter.getProject(cid),"正在获取主页数据中...")
            homeData.postValue(projectData)
        }
    }

}